#@adminLayout()

#define content()
#if(notice)
<script>
  alert("#(notice)");
</script>
#end
<div class="am-cf am-padding am-padding-bottom-0">
  <div class="am-fl am-cf">
    <strong class="am-text-primary am-text-lg">当日计划列表</strong>
  </div>
  <div style="float: right">
    <button class="am-btn am-btn-success am-btn-xs" onclick="window.location.href='/admin/scheduler/add'"><span class="am-icon-plus"></span>
      添加条目
    </button>
  </div>
</div>
<hr>
<div class="am-g">
  <div class="am-u-sm-12">
      <table class="am-table am-table-striped am-table-hover table-main">
        <thead>
        <tr>
          <th class="table-id">ID</th>
          <th class="table-title">公司名称</th>
          <th class="table-type">车牌号</th>
          <th class="table-author am-hide-sm-only">入库时间</th>
          <th class="table-author am-hide-sm-only">入库位置</th>
          <th class="table-author am-hide-sm-only">当前状态</th>
          <th class="table-set">操作</th>
        </tr>
        </thead>
        <tbody>
        #for(scheduler : schedulerList)
        <tr>
          <td>#(for.count)</td>
          <td>#(scheduler.company)</td>
          <td>#(scheduler.van)</td>
          <td class="am-hide-sm-only">#(tools.getDateTimeStr(scheduler.planTime))</td>
          <td class="am-hide-sm-only">#(scheduler.position)</td>
          <td class="am-hide-sm-only">#(status.getStr(scheduler.status))</td>
          <td>
            <div class="am-btn-toolbar">
              #if(scheduler.status == status.WAIT)
              <button type="button" class="am-btn am-btn-primary am-btn-xs" onclick="edit('#(scheduler.id)', '#(scheduler.company):#(scheduler.van)');"><span
                  class="am-icon-edit"></span>
                修改</button>
              <button type="button" class="am-btn am-btn-warning am-btn-xs" onclick="cancel('#(scheduler.id)', '#(scheduler.company):#(scheduler.van)');"><span
                  class="am-icon-recycle"></span>
                取消</button>
              <button type="button" class="am-btn am-btn-danger am-btn-xs" onclick="del('#(scheduler.id)', '#(scheduler.company):#(scheduler.van)');"><span
                  class="am-icon-remove"></span>
                删除</button>
              #end
            </div>
          </td>
        </tr>
        #else
        <tr>
          <td colspan="7" style="text-align: center">暂无记录</td>
        </tr>
        #end
        </tbody>
      </table>
  </div>
</div>

<script type="text/javascript">
  function edit(id) {
    var url = "/admin/scheduler/edit?id=" + id;
    window.location.href = url;
  }

  function del(id, desc) {
    if(confirm("确认删除任务 [" + desc + "]?")) {
      var url = "/admin/scheduler/delete?id=" + id;
      window.location.href = url;
    }
  }

  function cancel(id, desc) {
    if(confirm("确认取消任务 [" + desc + "]？")) {
      var url = "/admin/scheduler/cancel?id=" + id;
      window.location.href = url;
    }
  }
</script>
#end